<template>
  <div class="university_table">
    <div
      class="university_navigation"
      :class="{ university_dynamic: selected===3 }"
      @click="tablist(3)"
    >
      <div class="market-table-van">
        <van-icon name="shop-o" size="0.7rem"/>
      </div>
      <div class="market-table-word">市场</div>
    </div>
    <div
      class="university_navigation"
      :class="{university_dynamic: selected===5}"
      @click="tablist(5)"
    >
      <div class="market-table-van">
        <van-icon name="friends-o" size="0.7rem"/>
      </div>
      <div class="market-table-word">圈子</div>
    </div>
    <div
      class="university_navigation"
      :class="{ university_dynamic: selected===4 }"
      @click="tablist(4)"
    >
      <div class="market-table-van">
        <van-icon name="contact" size="0.7rem"/>
      </div>
      <div class="market-table-word">我的</div>
    </div>
  </div>
</template>
<script>
import { Icon } from "vant";
export default {
  name: "App",
  components: {
    [Icon.name]: Icon
  },
  data() {
    return {
      selected: 1
    };
  },
  computed: {},
  created() {
    this.checkRouter();
  },
  methods: {
    tablist(n) {
      this.selected = n;
      switch (n) {
        case 3:
          this.$router.push({ path: "/conversation" });
          break;
        case 4:
          this.$router.push({ path: "/personal" });
          break;
        case 5:
          this.$router.push({ path: "/partner" });
      }
    },
    // 检测现在在哪个路由下
    checkRouter() {
      let crouter = window.location.href;
      if (crouter.indexOf("teamlist") !== -1) {
        this.selected = 1;
      } else if (crouter.indexOf("seller") !== -1) {
        this.selected = 2;
      } else if (crouter.indexOf("conversation") !== -1) {
        this.selected = 3;
      } else if (crouter.indexOf("personal") !== -1) {
        this.selected = 4;
      } else if (crouter.indexOf("partner") !== -1) {
        this.selected = 5;
      }
    }
  }
};
</script>
<style lang="less"  scoped>
.university_table {
  width: 100%;
  display: flex;
  left: 0;
  bottom: 0;
  position: fixed;
  font-size: 0.4rem;
  height: 1.4rem;
  line-height: 1.4rem;
  background: #f5f5f5;
  border-top: 1px solid #d2c8c8;
}
.university_navigation {
  flex: 1;
  text-align: center;
}

.market-table-van {
  height: 0.9rem;
  color: #333333;
}
.market-table-word {
  height: 0.5rem;
  font-size: 0.3rem;
  line-height: 0.5rem;
  color: #333333;
}

.university_dynamic {
  cursor: pointer;

  border-top-right-radius: 0.1rem;
  border-top-left-radius: 0.1rem;
  .market-table-van {
    color: #e82323 !important;
  }
  .market-table-word {
    color: #e82323 !important;
  }
}
</style>

